package es.gesfutbol.domini.implementacio;

import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import es.gesfutbol.domini.IPartitDeQuiniela;

@Entity
@Table(name="partit_quiniela")
public class PartitDeQuiniela implements IPartitDeQuiniela {

	/**
	 * 
	 */
	private static final long serialVersionUID = 8942004121506743951L;

	private Long idPartitDeQuiniela;
	
	private Integer posicioQuiniela;
	
	private String resultat;
	
	private String analisi;
	
	private Partit partit;
	
	private Quiniela quiniela;
	
	private Set<Pronostic> pronostics;

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name="idPartitDeQuiniela", nullable=false, precision = 10, scale=0)
	public Long getIdPartitDeQuiniela() {
		return idPartitDeQuiniela;
	}

	public void setIdPartitDeQuiniela(Long idPartitDeQuiniela) {
		this.idPartitDeQuiniela = idPartitDeQuiniela;
	}

	@Column(name="posicioQuiniela", length=45, nullable=false)
	public Integer getPosicioQuiniela() {
		return posicioQuiniela;
	}

	public void setPosicioQuiniela(Integer posicioQuiniela) {
		this.posicioQuiniela = posicioQuiniela;
	}
	
	@Column(name="resultat", nullable=true, length=45)
	public String getResultat() {
		return resultat;
	}

	public void setResultat(String resultat) {
		this.resultat = resultat;		
	}
	

	@Column(name="analisi", nullable=true, length=1000)
	public String getAnalisi() {
		return analisi;
	}

	public void setAnalisi(String analisi) {
		this.analisi = analisi;
		
	}

	@OneToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="idPartit")
	public Partit getPartit() {
		return partit;
	}

	public void setPartit(Partit partit) {
		this.partit = partit;
	}

	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="idQuiniela" , nullable=false)
	public Quiniela getQuiniela() {
		return quiniela;
	}

	public void setQuiniela(Quiniela quiniela) {
		this.quiniela = quiniela;
	}

	@OneToMany(fetch=FetchType.LAZY, mappedBy="partitDeQuiniela", cascade=CascadeType.ALL)
	public Set<Pronostic> getPronostics() {
		return pronostics;
	}

	public void setPronostics(Set<Pronostic> pronostics) {
		this.pronostics = pronostics;
	}
}
